package com.mengxin.secondkill.message.redisqueue;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;

/**
 * @author mengxin
 * @date 2020/12/23 15:55
 */
@Data
@NoArgsConstructor
public class MsgData {

    private Object data;

    public MsgData(Object data){
        this.data = data;
    }

    /**
     * @return
     */
    public Map<String,Object> msgConvert(){
        Map<String,Object> resMap = new HashMap<>(1);
        JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(this));
        for(String key:jsonObject.keySet()){
            resMap.put(key,jsonObject.get(key));
        }
        return resMap;
    }
}
